<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>社交网站 - 顶部导航组件</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  
  <style>
    /* 基础样式 */
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: #f8fafc;
      color: #212529;
      padding-top: 56px; /* 为固定顶部导航留出空间 */
    }
    
    .container {
      max-width: 540px;
      margin: 0 auto;
      padding: 0 15px;
    }
    
    /* 主顶部导航 */
    .main-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 56px;
      background-color: white;
      box-shadow: 0 2px 5px rgba(0,0,0,0.05);
      z-index: 1000;
      display: flex;
      align-items: center;
      padding: 0 15px;
    }
    
    .logo {
      font-size: 20px;
      font-weight: 700;
      color: #0d6efd;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    
    .logo i {
      font-size: 24px;
    }
    
    .header-actions {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 15px;
    }
    
    .header-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: none;
      border: none;
      color: #6c757d;
      font-size: 18px;
      cursor: pointer;
      position: relative;
    }
    
    .header-btn:hover {
      background-color: #f1f5f9;
      color: #0d6efd;
    }
    
    .notification-badge {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background-color: #dc3545;
      color: white;
      font-size: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .user-avatar {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid transparent;
      cursor: pointer;
    }
    
    .user-avatar:hover {
      border-color: #0d6efd;
    }
    
    /* 次级导航菜单 */
    .secondary-nav {
      background-color: white;
      border-bottom: 1px solid #e9ecef;
      overflow-x: auto;
      padding: 0 15px;
    }
    
    .nav-tabs {
      display: flex;
      list-style: none;
      margin: 0;
      padding: 0;
      white-space: nowrap;
    }
    
    .nav-tab {
      padding: 12px 18px;
      font-size: 15px;
      font-weight: 500;
      color: #6c757d;
      cursor: pointer;
      position: relative;
    }
    
    .nav-tab.active {
      color: #0d6efd;
    }
    
    .nav-tab.active::after {
      content: '';
      position: absolute;
      bottom: -1px;
      left: 0;
      right: 0;
      height: 3px;
      background-color: #0d6efd;
      border-radius: 3px 3px 0 0;
    }
    
    .nav-tab:hover {
      color: #0d6efd;
      background-color: #f8fafc;
    }
    
    /* 内容区域 */
    .content-section {
      padding: 20px 0;
    }
    
    .card {
      background-color: white;
      border-radius: 12px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.05);
      padding: 15px;
      margin-bottom: 15px;
    }
    
    /* 个人中心顶部 */
    .profile-header {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      background-color: #0d6efd;
      color: white;
      z-index: 1001;
    }
    
    .profile-header.active {
      display: block;
    }
    
    .profile-header-top {
      padding: 15px;
      display: flex;
      align-items: center;
    }
    
    .back-btn {
      background: none;
      border: none;
      color: white;
      font-size: 20px;
      margin-right: 15px;
      cursor: pointer;
    }
    
    .profile-title {
      font-size: 18px;
      font-weight: 600;
      flex: 1;
    }
    
    .profile-actions {
      display: flex;
      gap: 10px;
    }
    
    .profile-action-btn {
      background: none;
      border: none;
      color: white;
      font-size: 18px;
      cursor: pointer;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .profile-action-btn:hover {
      background-color: rgba(255,255,255,0.2);
    }
    
    .profile-cover {
      height: 160px;
      background: linear-gradient(135deg, #0d6efd, #3b82f6);
      position: relative;
    }
    
    .profile-avatar-large {
      width: 90px;
      height: 90px;
      border-radius: 50%;
      object-fit: cover;
      border: 4px solid white;
      position: absolute;
      bottom: -45px;
      left: 20px;
    }
    
    .profile-info {
      padding: 55px 20px 20px;
    }
    
    .profile-name {
      font-size: 22px;
      font-weight: 700;
      margin: 0 0 5px 0;
    }
    
    .profile-bio {
      font-size: 14px;
      color: rgba(255,255,255,0.9);
      margin: 0 0 15px 0;
    }
    
    .profile-stats {
      display: flex;
      gap: 20px;
      margin-bottom: 15px;
    }
    
    .profile-stat {
      text-align: center;
    }
    
    .stat-value {
      font-size: 18px;
      font-weight: 700;
      margin: 0 0 3px 0;
    }
    
    .stat-label {
      font-size: 12px;
      color: rgba(255,255,255,0.8);
      margin: 0;
    }
    
    .profile-nav {
      display: flex;
      border-top: 1px solid rgba(255,255,255,0.2);
    }
    
    .profile-nav-item {
      flex: 1;
      text-align: center;
      padding: 12px 0;
      font-size: 14px;
      font-weight: 500;
      color: rgba(255,255,255,0.8);
      cursor: pointer;
      border-bottom: 3px solid transparent;
    }
    
    .profile-nav-item.active {
      color: white;
      border-bottom-color: white;
    }
    
    /* 个人中心内容 */
    .profile-content {
      display: none;
      padding-top: 440px; /* 为个人中心顶部留出空间 */
      min-height: 100vh;
      background-color: #f8fafc;
    }
    
    .profile-content.active {
      display: block;
    }
    
    /* 主内容区域 */
    .main-content {
      display: block;
    }
    
    .main-content.hidden {
      display: none;
    }
    
    /* 提示框 */
    .toast {
      position: fixed;
      top: 70px;
      left: 50%;
      transform: translateX(-50%);
      background-color: rgba(0,0,0,0.8);
      color: white;
      border-radius: 8px;
      padding: 12px 20px;
      font-size: 15px;
      z-index: 10000;
      display: none;
    }
  </style>
</head>
<body>
  <!-- 主顶部导航 -->
  <header class="main-header" id="mainHeader">
    <a href="#" class="logo">
      <i class="fa fa-connectdevelop"></i>
      <span>社交圈</span>
    </a>
    
    <div class="header-actions">
      <button class="header-btn search-btn">
        <i class="fa fa-search"></i>
      </button>
      <button class="header-btn notification-btn">
        <i class="fa fa-bell-o"></i>
        <span class="notification-badge">3</span>
      </button>
      <button class="header-btn message-btn">
        <i class="fa fa-envelope-o"></i>
      </button>
      <img src="https://picsum.photos/200/200?random=1" alt="用户头像" class="user-avatar" id="userAvatar">
    </div>
  </header>
  
  <!-- 次级导航菜单 -->
  <nav class="secondary-nav">
    <ul class="nav-tabs">
      <li class="nav-tab active" data-tab="recommended">推荐</li>
      <li class="nav-tab" data-tab="following">关注</li>
      <li class="nav-tab" data-tab="trending">热门</li>
      <li class="nav-tab" data-tab="nearby">附近</li>
      <li class="nav-tab" data-tab="live">直播</li>
      <li class="nav-tab" data-tab="topics">话题</li>
    </ul>
  </nav>
  
  <!-- 主内容区域 -->
  <div class="main-content" id="mainContent">
    <div class="container">
      <div class="content-section">
        <div class="card">
          <h3>推荐内容</h3>
          <p>这是社交平台的推荐内容区域，根据您的兴趣和关注为您推送精选内容。</p>
        </div>
        <div class="card">
          <h3>热门话题</h3>
          <p>#人工智能 #科技创新 #生活方式 #旅行日记 #美食分享</p>
        </div>
        <div class="card">
          <h3>活动推荐</h3>
          <p>本周末将举办线下社交聚会，点击查看详情并报名参与。</p>
        </div>
      </div>
    </div>
  </div>
  
  <!-- 个人中心顶部 -->
  <div class="profile-header" id="profileHeader">
    <div class="profile-header-top">
      <button class="back-btn" id="backToMain">
        <i class="fa fa-arrow-left"></i>
      </button>
      <h1 class="profile-title">个人中心</h1>
      <div class="profile-actions">
        <button class="profile-action-btn edit-btn">
          <i class="fa fa-edit"></i>
        </button>
        <button class="profile-action-btn settings-btn">
          <i class="fa fa-cog"></i>
        </button>
      </div>
    </div>
    
    <div class="profile-cover">
      <img src="https://picsum.photos/200/200?random=1" alt="用户头像" class="profile-avatar-large">
    </div>
    
    <div class="profile-info">
      <h2 class="profile-name">张明</h2>
      <p class="profile-bio">热爱生活，分享美好 | 摄影师 | 旅行爱好者</p>
      
      <div class="profile-stats">
        <div class="profile-stat">
          <p class="stat-value">248</p>
          <p class="stat-label">动态</p>
        </div>
        <div class="profile-stat">
          <p class="stat-value">1.2k</p>
          <p class="stat-label">粉丝</p>
        </div>
        <div class="profile-stat">
          <p class="stat-value">356</p>
          <p class="stat-label">关注</p>
        </div>
        <div class="profile-stat">
          <p class="stat-value">4.8k</p>
          <p class="stat-label">获赞</p>
        </div>
      </div>
      
      <div class="profile-nav">
        <div class="profile-nav-item active" data-profile-tab="posts">动态</div>
        <div class="profile-nav-item" data-profile-tab="photos">相册</div>
        <div class="profile-nav-item" data-profile-tab="likes">点赞</div>
        <div class="profile-nav-item" data-profile-tab="collections">收藏</div>
      </div>
    </div>
  </div>
  
  <!-- 个人中心内容 -->
  <div class="profile-content" id="profileContent">
    <div class="container">
      <div class="content-section">
        <div class="card">
          <h3>我的动态</h3>
          <p>这是您发布的最新动态内容...</p>
        </div>
        <div class="card">
          <h3>最近相册</h3>
          <p>您最近上传的照片将显示在这里...</p>
        </div>
        <div class="card">
          <h3>活动记录</h3>
          <p>您参与的活动和获得的成就...</p>
        </div>
      </div>
    </div>
  </div>
  
  <!-- 提示框 -->
  <div class="toast" id="toast">操作成功</div>
  
  <!-- Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <script>
    // 获取元素
    const userAvatar = document.getElementById('userAvatar');
    const mainHeader = document.getElementById('mainHeader');
    const profileHeader = document.getElementById('profileHeader');
    const mainContent = document.getElementById('mainContent');
    const profileContent = document.getElementById('profileContent');
    const backToMain = document.getElementById('backToMain');
    const navTabs = document.querySelectorAll('.nav-tab');
    const profileNavItems = document.querySelectorAll('.profile-nav-item');
    const toast = document.getElementById('toast');
    
    // 显示提示
    function showToast(message) {
      toast.textContent = message;
      toast.style.display = 'block';
      
      setTimeout(() => {
        toast.style.display = 'none';
      }, 2000);
    }
    
    // 切换到个人中心
    userAvatar.addEventListener('click', function() {
      mainHeader.style.display = 'none';
      document.querySelector('.secondary-nav').style.display = 'none';
      mainContent.classList.add('hidden');
      profileHeader.classList.add('active');
      profileContent.classList.add('active');
      window.scrollTo(0, 0);
    });
    
    // 返回主页面
    backToMain.addEventListener('click', function() {
      profileHeader.classList.remove('active');
      profileContent.classList.remove('active');
      mainHeader.style.display = 'flex';
      document.querySelector('.secondary-nav').style.display = 'block';
      mainContent.classList.remove('hidden');
    });
    
    // 次级导航菜单切换
    navTabs.forEach(tab => {
      tab.addEventListener('click', function() {
        navTabs.forEach(t => t.classList.remove('active'));
        this.classList.add('active');
        showToast(`切换到${this.textContent}页面`);
      });
    });
    
    // 个人中心导航切换
    profileNavItems.forEach(item => {
      item.addEventListener('click', function() {
        profileNavItems.forEach(i => i.classList.remove('active'));
        this.classList.add('active');
        showToast(`查看${this.textContent}`);
      });
    });
    
    // 头部按钮事件
    document.querySelector('.search-btn').addEventListener('click', () => {
      showToast('打开搜索页面');
    });
    
    document.querySelector('.notification-btn').addEventListener('click', () => {
      showToast('查看通知消息');
    });
    
    document.querySelector('.message-btn').addEventListener('click', () => {
      showToast('打开消息列表');
    });
    
    document.querySelector('.edit-btn').addEventListener('click', () => {
      showToast('编辑个人资料');
    });
    
    document.querySelector('.settings-btn').addEventListener('click', () => {
      showToast('打开设置页面');
    });
  </script>
</body>
</html>